<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" />

    <script>
      function debounce(handle, duration = 1000) {
        let timer = null;
        return function () {
          const _self = this,
            _arg = arguments;
          clearTimeout(timer);
          timer = setTimeout(function () {
            return handle.apply(_self, _arg);
          }, duration);
        };
      }

      const inpEl = document.querySelector("input");
      inpEl.oninput = debounce(function (e) {
        console.log(this.value, e);
      });
    </script>
  </body>
</html>
